package com.li.youhappygo.controller;

import com.li.youhappygo.annotation.Log;
import com.li.youhappygo.annotation.OperatorType;
import com.li.youhappygo.model.entity.system.ShopInfo;
import com.li.youhappygo.model.vo.common.Result;
import com.li.youhappygo.model.vo.common.ResultCode;
import com.li.youhappygo.service.ShopInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Tag(name = "店铺信息管理", description = "店铺信息管理")
public class ShopController {

    @Autowired
    ShopInfoService shopInfoService;

    @GetMapping("getShopInfo/{shopId}")
    @Operation(summary = "根据ID查询店铺信息",description = "根据ID查询店铺信息")
    public Result<ShopInfo> getShopInfo(@PathVariable Integer shopId) {
        ShopInfo shopInfo = shopInfoService.getShopInfo(shopId);
        return Result.build(shopInfo, ResultCode.SUCCESS);
    }

    @PostMapping("insertShopInfo")
    @Operation(summary = "插入店铺信息",description = "插入店铺信息")
    @Log(title = "插入店铺信息", businessType = 1,operatorType = OperatorType.MANAGE)
    public Result insertShopInfo(@RequestBody ShopInfo shopInfo) {
        shopInfoService.insertShopInfo(shopInfo);
        return Result.build(null, ResultCode.SUCCESS);
    }

    @PostMapping("updateShopInfo")
    @Operation(summary = "更新店铺信息",description = "更新店铺信息")
    @Log(title = "更新店铺信息", businessType = 2,operatorType = OperatorType.MANAGE)
    public Result updateShopInfo(@RequestBody ShopInfo shopInfo) {
        shopInfoService.updateShopInfo(shopInfo);
        return Result.build(null, ResultCode.SUCCESS);
    }

}
